package com.hxf.web.action.admin;

import java.io.IOException;
import java.util.List;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.hxf.dto.MealMenuDto;
import com.hxf.dto.ReturnData;
import com.hxf.exception.ServiceException;
import com.hxf.web.action.WebActionBase;

/**
 * 菜肴管理
 * @author tengyicheng
 *
 */
@Results({@Result(name = "success", location = "../common/success.jsp"), @Result(name = "error", location = "../common/error.jsp"), @Result(name = "msg", location = "../common/msg.jsp")})
public class DishesAction extends WebActionBase {
	private List<MealMenuDto> mealMenuDtoList;
	private String mealMenuIds;
	private Integer status;
	private String menuName;
	
	/**
	 * 菜肴列表
	 * @return
	 */
	public String dishesList() {
		try {
			MealMenuDto mealMenu = null;
			if(null != menuName){
				mealMenu = new MealMenuDto();
				mealMenu.setMenuName(menuName);
			}
			ReturnData<MealMenuDto> result = super.serviceFacade.getMealMenuService().findByMealMenu(mealMenu, targetPage, pageSize);
			mealMenuDtoList = result.getResultlist();
			this.setRecordCount(result.getRecordcount());
		} catch (ServiceException e){ 
			e.printStackTrace();
		}
		return "dishes-list";
	}
	
	/**
	 * 审核通过和审核不通过
	 * @return
	 */
	public String audit() {
		try {
			int result = super.serviceFacade.getMealMenuService().updateMealMenuStatus(mealMenuIds, status);
			println(result);
		} catch (ServiceException e) {
			logger.debug(e.getMessage(), e);
		} catch (IOException e) {
			logger.debug(e.getMessage(), e);
		}
		 return null;
	}

	public List<MealMenuDto> getMealMenuDtoList() {
		return mealMenuDtoList;
	}

	public void setMealMenuDtoList(List<MealMenuDto> mealMenuDtoList) {
		this.mealMenuDtoList = mealMenuDtoList;
	}

	public String getMealMenuIds() {
		return mealMenuIds;
	}

	public void setMealMenuIds(String mealMenuIds) {
		this.mealMenuIds = mealMenuIds;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getMenuName() {
		return menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}
	
	
}
